﻿$(function () {
    ajaxCall('DataService.asmx/GetAdditionalStuff', false, "",
                function (msg) {

                    $('#youTubeVideo').append(msg.d.EmbededVideo);
                },
                function () {
                    alert("Error happend while reading from database");
                }
            );

    $.ajax({
        type: 'POST',
        async: false,
        contentType: 'application/json; charset=utf-8',
        url: '../DataService.asmx/GetNotifications',
        dataType: 'json',
        success: function (msg) {
            var go;
            if (msg.d.length > 5) {
                go = 5;
                $('#allNotif').css('display', 'initial');
            } 
            else {
                go = msg.d.length;
            }

            for (var i = 0; i < go; i++) {
                var announcements = [
                        { ID: msg.d[i].ID, Title: msg.d[i].Title, Date: JSONDate(msg.d[i].Date), Description: msg.d[i].Description, Link: msg.d[i].Link },
                    ];

                $('#AnnouncementTemplate').tmpl(announcements).appendTo('#Announcements');
            }
        }
    });

});